<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>练习 - 网页时钟</title>
    <style>
        * {
            box-sizing: border-box;
        }

        .clock {
            width: 600px;
            height: 600px;
            background: url(./images/clock.jpg) no-repeat;
            margin: 50px auto 0;
            position: relative;
        }

        .hh,
        .mm,
        .ss {
            position: absolute;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            background: url(./images/hour.png) no-repeat center;
        }

        .hh {
            background-image: url(./images/hour.png);
            transform: rotate(0deg);
        }

        .mm {
            background-image: url(./images/minute.png);
            transform: rotate(0deg);
        }

        .ss {
            background-image: url(./images/second.png);
            transform: rotate(0deg);
        }
    </style>
</head>

<body>
    <div class="clock">
        <div class="hh" id="h"></div>
        <div class="mm" id="m"></div>
        <div class="ss" id="s"></div>
    </div>
    <script>
        //获取对象元素
        let sz = document.querySelector('.ss')
        let mm = document.querySelector('.mm')
        let hh = document.querySelector('.hh')

        // 定义一个变量来控制指针旋转度数
        let ss = 0
        let xh = 0
        let hhh = 0
        // 开启一个定时器 每间隔一秒就调用一次 
        setInterval(function () {
            ss += 6
            sz.style.transform = `rotate(${ss}deg)`
            if (ss === 360) {
                ss = 0
                xh += 6
                hhh += 0.5
                mm.style.transform = `rotate(${xh}deg)`
                hh.style.transform = `rotate(${hhh}deg)`
            }


        }, 5)

    </script>
</body>

</html>